package com.lxl;

import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.exception.KettleException;

import java.util.logging.Level;
import java.util.logging.Logger;

public class KettleEnvironmentLauncher {
    private static boolean running;//私有boolean不要用is开头
    private static Logger LOGGER;

    static{
        LOGGER = Logger.getLogger(Launcher.class.getName());
        LOGGER.setLevel(Level.INFO);
    }

    public static void startKettleEnvironment(){
        try {
            if (!KettleEnvironment.isInitialized()){
                LOGGER.info("ETL environment begins to initialize.");
                KettleEnvironment.init();
                LOGGER.info("ETL environment finishes initializing.");
            }
        } catch (KettleException e) {
            LOGGER.info(" ETL environment init failed.");
            e.printStackTrace();
        }
    }

    public static void stopKettleEnvironment(){
        if (KettleEnvironment.isInitialized()){
            KettleEnvironment.shutdown();
        }
    }

    public boolean isRunning(){
        return running;
    }
}
